﻿using System.Configuration;

namespace WordStat
{
    internal class WordStatSettings
    {
        public void LoadFromAppConfig()
        {
            var res = ConfigurationManager.AppSettings.Get("RowsOnMainPage");
            if (res != null)
            {
                if (!int.TryParse(res, out _rowNumber))
                    _rowNumber = 20;
            }
        }

        public void SaveToAppConfig()
        {
            ConfigurationManager.AppSettings.Set("RowsOnMainPage", _rowNumber.ToString());
        }

        private int _rowNumber = 20;
        public int RowNumber
        {
            get { return _rowNumber; }
            set
            {
                if (value <= 0)
                    return;

                _rowNumber = value;
            }
        }
    }
}
